Page({

  /**
   * 页面的初始数据
   */
  data: {
    temp: "0℃",
    low: "0℃",
    height: "0℃",
    type: "晴",
    city: "广州",
    date: "1日,星期一",
    msg: "无持续风向",
    wind: "微风级",
    weatherArray: []

  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getWeather()
  },
  getWeather: function () {
    var thispage = this
    wx: wx.request({
      url: 'https://www.tianqiapi.com/api/',
      method: 'GET',
      data: {
        appid: '23035354',
        appsecret: '8YvlPNrz',
        version: 'v9',
        cityid: '',
        city: '珠海',
        ip: '',
        callback: ''
      },
      success: function (res) {
        console.log("there is weather data.")
        console.log(res)
        let today=res.data.data[0]
        thispage.setData({
          temp: today.tem,
          height: today.tem1,
          low:today.tem2,
          type: today.wea,
          city: res.data.city,
          date:today.day,
          msg: today.air_tips,
          wind: today.win_speed,
          weatherArray:res.data.data
        })
        wx.setNavigationBarTitle({
          title: thispage.data.city,
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})